package com.sz.ruichar.service.entity.model.result;

/**
 * 详细返回信息实体: 注意该实体不能直接返回 必须作为ResultModel的data参数
 */
public class ResultData 
{
	private static final int SUCCESS = 201;
	
	private static final int ERROR = 501;
	
	/**
     * 业务码
     */
    private int code;	//201代表成功,501代表失败

    /**
     * 返回结果描述
     */
    private String msg;

    /**
     * 返回内容
     */
    private Object info;
    
    public ResultData(int code, String msg, Object info) {
		super();
		this.code = code;
		this.msg = msg;
		this.info = info;
	}

    
    public static ResultData success()
    {
    	ResultData result = new ResultData(SUCCESS, "成功", null);
    	return result;
    }
    public static ResultData success(Object data)
    {
    	ResultData result = new ResultData(SUCCESS, "成功", data);
    	return result;
    }
    public static ResultData error(String msg)
    {
    	ResultData result = new ResultData(ERROR, msg, null);
    	return result;
    }
    public static ResultData error()
    {
    	ResultData result = new ResultData(ERROR, "系统错误", null);
    	return result;
    }
    
	public int getCode() {
		return code;
	}

	public void setCode(int code) {
		this.code = code;
	}

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}


	public Object getInfo() {
		return info;
	}

	public void setInfo(Object info) {
		this.info = info;
	}

	@Override
	public String toString() {
		return "ResultData{" +
				"code=" + code +
				", msg='" + msg + '\'' +
				", info=" + info +
				'}';
	}
}
